﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.Processiings_FourWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Processiings_FourWayAllController : ControllerBase
    {
        IMediator mediator;

        public Processiings_FourWayAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<ApiResult<int>> AddFourWayAll(Processiings_Four Processiings_Four)
        {
            try
            {
                AddFourWayCommand AddFourWayCommand = new AddFourWayCommand()
                {
                    Processiings_Four = Processiings_Four
                };
                return await mediator.Send(AddFourWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Processiings_Four>> FirstNextSlaughts([FromQuery] FirstFourWayCommand FirstFourWayCommand)
        {
            try
            {
                return await mediator.Send(FirstFourWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateNextSlaughts(Processiings_Four Processiings_Four)
        {
            try
            {
                UpdateFourWayCommand UpdateFourWayCommand = new UpdateFourWayCommand()
                {
                    Processiings_Four = Processiings_Four
                };
                return await mediator.Send(UpdateFourWayCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
